package com.htsk.city.services.wechat.controller;

import com.htsk.city.services.core.domain.WxUser;
import com.htsk.city.services.core.entity.R;
import com.htsk.city.services.wechat.annotation.GetUserInfo;
import com.htsk.city.services.wechat.service.WechatService;
import com.htsk.city.services.wechat.vo.UserInfoVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping()
public class WechatController {

    @Resource
    private WechatService wechatService;

    @GetMapping("login")
    public R<String> login(@RequestParam("code")String code){
        return wechatService.wxLogin(code);
    }

    @GetMapping("userInfo")
    public R<UserInfoVO> userInfo(@GetUserInfo WxUser wxUser){
        return wechatService.getUserInfo(wxUser);
    }

    @PostMapping("saveUserInfo")
    public R<Boolean> saveUserInfo(@GetUserInfo WxUser wxUser,@RequestBody UserInfoVO userInfo){
        return wechatService.saveUserInfo(wxUser,userInfo);
    }
}
